<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<section class="content-header">
    <h1>出库单冲单</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">

                                <div class="form-group">
                                    <label for="query-prodNo">生产令号</label>
                                    <input id="query-prodNo" type="text" name="prodNo" class="form-control"
                                           placeholder="请输入生产令号">
                                </div>
                                <div class="form-group">
                                    <label for="query-proName">项目名称</label>
                                    <input id="query-proName" type="text" name="proName" class="form-control"
                                           placeholder="请输入项目名称">
                                </div>
                                <div class="form-group">
                                    <label for="query-drawName">零件名称</label>
                                    <input id="query-drawName" type="text" name="drawName" class="form-control"
                                           placeholder="请输入零件名称">
                                </div>
                                <div class="form-group">
                                    <label for="query-drawNo">图号</label>
                                    <input id="query-drawNo" type="text" name="drawNo" class="form-control"
                                           placeholder="请输入图号">
                                </div>
                                <div class="form-group">
                                    <label for="query-createName">创建人</label>
                                    <input id="query-createName" type="text" name="createName" class="form-control"
                                           placeholder="请输入创建人">
                                </div>
                                <!--<div class="form-group">-->
                                <!--<label for="query-isDebugging">是否需要调试</label>-->
                                <!--<select id="query-isDebugging" class="form-control" name="isDebugging">-->
                                <!--<option value="" selected>全部</option>-->
                                <!--<option value="1">需要</option>-->
                                <!--<option value="2">不需要</option>-->
                                <!--</select>-->
                                <!--</div>-->
                                <!--<div class="form-group">-->
                                    <!--<label for="query-debuggingStatu">状态</label>-->
                                    <!--<select id="query-debuggingStatu" class="form-control" name="subStatus">-->
                                        <!--<option value="">全部</option>-->
                                        <!--<option value="1" selected>未提交</option>-->
                                        <!--<option value="2">待审核</option>-->
                                        <!--<option value="3">已审核</option>-->
                                    <!--</select>-->
                                <!--</div>-->
                                <div class="form-group">
                                    <label for="query-startTime">创建日期</label>
                                    <input id="query-startTime" type="text" class="form-control datepicker"
                                           name="startTime"
                                           readonly="readonly"/>
                                    <label for="query-endTime"> 至 </label>
                                    <input id="query-endTime" type="text" class="form-control datepicker" name="endTime"
                                           readonly="readonly"/>
                                </div>
                                <button type="button" class="btn btn-success" id="btn-search"
                                        onclick="js.table.search(table)">
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    let table;
    var statusName = ["", "未提交", "已提交", "已审核"];
    var classType = ["label-primary", " label-default", " label-warning", " label-success"];

    $(function () {

        table = js.table.init({
            url: ctx + "delivery/submitList",
            showExport: false,
            columns: [
                {
                    title: '序号', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: "生产令号", field: 'prodNo'},
                {title: "项目名称", field: 'proName', width: '220'},
                // {title: "类型", field: 'special'},
                // {title: "部分", field: 'part', width: '50'},
                {title: "零件名称", field: 'drawName', width: '200'},
                {title: "图号", field: 'drawNo', width: '200'},
                {title: "零件数量", field: 'drawNum'},
                // {
                //     title: "状态", field: 'submitStatus', width: '80',
                //     formatter: function (value) {
                //         return '<span class="badge' + classType[value] + '">' + statusName[value] + '</span>';
                //     }
                // },
                {title: "创建人", field: 'createName'},
                {title: "部门", field: 'dept', width: '100'},
                {title: "创建日期", field: 'createTime', width: '100'},
                {
                    title: "操作",
                    formatter: function (value, row) {
                        let actions = [];
                        actions.push('<a class="btn btn-info btn-xs" target="_blank"  href="' + ctx + 'delivery/makeView/' + row.sheetId + '" > 查看</a>');
                        actions.push('<a class="btn btn-danger btn-xs" shiro:hasPermission="conInstall:delivery:del" onclick="del(' + row.id + ')" > 冲单</a> ');
                        // if (row.submitStatus==1){
                        //     actions.push('<a class="btn btn-success btn-xs" shiro:hasPermission="conInstall:crecom:commit"  onclick="submit(' + row.id + ')"> 提交</a> ');
                        //     actions.push('<a class="btn btn-warning btn-xs" shiro:hasPermission="conInstall:crecom:edit"   href="' + ctx + 'create/dispatching/listDetailEdit/' + row.id + '" > 编辑</a> ');
                        // }
                        // if (row.submitStatus==2){
                        //     actions.push('<a class="btn btn-danger btn-xs" shiro:hasPermission="conInstall:crecom:del" onclick="del(' + row.id + ')" > 撤销</a> ');
                        // }
                        return actions.join('');
                    }
                }
            ]
        });
    });

    /** 提交数据待审核 */
    function submit(id) {
        js.modal.confirm("确定要提交吗？", function () {
            js.post({
                url: ctx + "create/dispatching/submit",
                data: {id: id},
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table);
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            })
        })
    }

    /** 提交数据待审核 */
    function del(id) {
        js.modal.confirm("确定要冲单吗？", function () {
            js.post({
                url: ctx + "delivery/del",
                data: {id: id},
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table);
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            })
        })
    }
</script>
</body>
</html>
